﻿function DepmetAdd(tree, treeRoot, selectNode, isTj) {
    if (selectNode) {
        parentNode = selectNode.parentNode;
        Ext.Msg.prompt("添加物品类别", "请输入物品名称", function (btn, text) {
            if (btn == "ok") {
                if (text != "") {
                    Ext.Ajax.request({
                        url: "server/StockRoomStuff/StockRoomStuffTypeAdd.aspx",
                        method: 'POST',
                        params: { text: text, parentnode: isTj ? ((parentNode != undefined && parentNode.id != "DepmetTreeRoot") ? parentNode.id : 0) : selectNode.id },
                        success: function (response) {
                            var json = Ext.util.JSON.decode(response.responseText);
                            if (json.success) {
                                Ext.Msg.alert("提示", json.msg);
                                tree.loader.load(treeRoot);
                            } else {
                                Ext.Msg.alert("错误", json.msg);
                            }
                        }
                    });
                } else {
                    Ext.Msg.alert("提示", "请输入名称");
                }
            }
        });
    }
}